﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using FredCK.FCKeditorV2;

namespace Common
{
    public static class PageHelper
    {
        public static string ShowActiveImage(string ActiveCode)
        {
            string strReturn = ActiveCode == "1" || ActiveCode == "True" ? "stop.png" : "start.png";
            return GlobalClass.GetUrlAdminImage() + strReturn;
        }

        public static string ShowCheckImage(string ActiveCode)
        {
            string strReturn = ActiveCode == "1" || ActiveCode == "True" ? "check.gif" : "uncheck.gif";
            return GlobalClass.GetUrlAdminImage() + strReturn;
        }

        public static string ShowActiveToolTip(string ActiveCode)
        {
            return ActiveCode == "1" || ActiveCode == "True" ? "Ẩn" : "Hiển thị";
        }

        public static  string ShowActiveStatus(string ActiveCode)
        {
            return ActiveCode == "1" || ActiveCode == "True" ? "Hiển thị" : "Ẩn";
        }
        public static string ShowActiveStatusAdmin(string ActiveCode)
        {
            return ActiveCode == "1" || ActiveCode == "True" ? "Có" : "Không";
        }
        public static bool Evaluate(string ActiveCode)
        {
            bool result = ActiveCode == "1";
            return result;
            //bool result = false;
            //if (ActiveCode == "1")
            //    result = true;
            //return result;
        }
        public static void ResetControlValues(Control parent)
        {
            foreach (Control c in parent.Controls)
            {
                if (c.Controls.Count > 0)
                {
                    if (c.GetType().ToString() == "FredCK.FCKeditorV2.FCKeditor")
                    {
                        ((FCKeditor)c).Value = "";
                        break;
                    }
                    ResetControlValues(c);
                }
                else
                {
                    switch (c.GetType().ToString())
                    {
                        case "System.Web.UI.WebControls.DropDownList":
                            ((DropDownList)c).Items.Clear();
                            break;
                        case "System.Web.UI.WebControls.TextBox":
                            ((TextBox)c).Text = "";
                            break;
                        case "System.Web.UI.WebControls.CheckBox":
                            ((CheckBox)c).Checked = false;
                            break;
                        case "System.Web.UI.WebControls.RadioButton":
                            ((RadioButton)c).Checked = false;
                            break;
                        //case "System.Web.UI.WebControls.Image":
                        //    ((Image)c).ImageUrl = null;
                        //    ((Image)c).Width = 0;
                        //    break;
                        case "FredCK.FCKeditorV2.FCKeditor":
                            ((FCKeditor)c).Value = "";
                            break;
                    }
                }
            }
        }
    }
}
